<?php

namespace Admin\Controller;

class CustomerController extends CommonController
{
    /**
     * 会员管理---首页
     */
    public function index()
    {
        //模糊查询
        if ($_GET) {
            $nickname = I('get.nickname');
            $mobile = I('get.mobile');
            $created_at = strtotime(I('get.created_at'));

            if ($nickname) {
                $map['nickname'] = array('like', "%" . $nickname . "%");
            }
            if ($mobile) {
                $map['mobile'] = array('like', "%" . $mobile . "%");
            }
            if ($created_at) {
                $map['created_at'] = array('like', "%" . $created_at . "%");
            }
        }

        $count = $this->customer->count();// 查询满足要求的总记录数
        $Page = new \Common\Util\Page($count, 5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $pages = $Page->show();// 分页显示输出
        $customers = $this->customer->where($map)->limit($Page->firstRow . ',' . $Page->listRows)->select();

        $this->assign(compact('customers', 'pages', 'count'));
        $this->display();
    }


}